package com.hryk.medical;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.View;

import com.baoteng.base.component.BaseActivity;
import com.baoteng.base.view.TopTitleBar;
import com.hryk.medical.common.adapter.ViewPagerAdapter;
import com.hryk.medical.common.view.TopNavigationBar;
import com.hryk.medical.education.ui.HealthEducationFragment;
import com.hryk.medical.health.ui.HealthServiceFragment;
import com.hryk.medical.life.ui.LifeServiceFragment;
import com.hryk.medical.medical.ui.MedicalServiceFragment;
import com.hryk.medical.video.ui.VideoFunFragment;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends BaseActivity {

    private TopNavigationBar navigationBar;
    private ViewPager mViewPager;
    private ViewPagerAdapter mAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.act_main);
        initView();
    }

    @Override
    public void initTitle(TopTitleBar topTitleBar) {
        topTitleBar.setVisibility(View.GONE);
    }

    private void initView() {
        navigationBar = findViewById(R.id.main_top_navigation);
        mViewPager = findViewById(R.id.main_content_pager);

        final List<Fragment> mFragments = new ArrayList<>();
        mFragments.add(new MedicalServiceFragment());
        mFragments.add(new HealthEducationFragment());
        mFragments.add(new VideoFunFragment());
        mFragments.add(new LifeServiceFragment());
        mFragments.add(new HealthServiceFragment());
        mAdapter = new ViewPagerAdapter(getSupportFragmentManager(), mFragments);
        mViewPager.setOffscreenPageLimit(mFragments.size());
        mViewPager.setAdapter(mAdapter);
        navigationBar.setupWithViewPager(mViewPager);
    }
}
